package p.ithorns.framework.xxljob;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * XxlJobConf
 * 
 * @author Ht.L
 * @date 2024-01-03 19:35
 * @since 1.0.0
 */
@ConfigurationProperties(prefix = "xxl.job")
public class XxlJobConf {

    /**
     * 是否开启
     */
    private boolean enabled;
    /**
     * token
     */
    private String accessToken;
    /**
     * Admin控制台配置
     */
    private Admin admin;
    /**
     * 执行器配置
     */
    private Executor executor;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Admin getAdmin() {
        return admin;
    }

    public void setAdmin(Admin admin) {
        this.admin = admin;
    }

    public Executor getExecutor() {
        return executor;
    }

    public void setExecutor(Executor executor) {
        this.executor = executor;
    }

    public static class Admin {
        /**
         * Admin地址
         */
        private String addresses;
        /**
         * 登录用户名
         */
        @JsonProperty("login-username")
        private String loginUsername;
        /**
         * 登录密码
         */
        @JsonProperty("login-pwd")
        private String loginPwd;

        public String getAddresses() {
            return addresses;
        }

        public void setAddresses(String addresses) {
            this.addresses = addresses;
        }

        public String getLoginUsername() {
            return loginUsername;
        }

        public void setLoginUsername(String loginUsername) {
            this.loginUsername = loginUsername;
        }

        public String getLoginPwd() {
            return loginPwd;
        }

        public void setLoginPwd(String loginPwd) {
            this.loginPwd = loginPwd;
        }
    }

    public static class Executor {

        /**
         * 执行器IP
         */
        private String ip;
        /**
         * 执行器端口
         */
        private int port;
        /**
         * 执行器(组)名称
         */
        @JsonProperty("appname")
        private String appName = "position-service";
        /**
         * 标题
         */
        private String title;
        /**
         * 执行器地址类型：0=自动注册、1=手动录入
         */
        @JsonProperty("address-type")
        private int addressType;
        /**
         * 执行器地址列表，多地址逗号分隔(手动录入)
         */
        @JsonProperty("address-list")
        private String addressList;
        /**
         * 日志路径
         */
        @JsonProperty("logpath")
        private String logPath;
        /**
         * 日志保存时长(天)
         */
        @JsonProperty("logretentiondays")
        private int logRetentionDays;

        public String getIp() {
            return ip;
        }

        public void setIp(String ip) {
            this.ip = ip;
        }

        public int getPort() {
            return port;
        }

        public void setPort(int port) {
            this.port = port;
        }

        public String getAppName() {
            return appName;
        }

        public void setAppName(String appName) {
            this.appName = appName;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public int getAddressType() {
            return addressType;
        }

        public void setAddressType(int addressType) {
            this.addressType = addressType;
        }

        public String getAddressList() {
            return addressList;
        }

        public void setAddressList(String addressList) {
            this.addressList = addressList;
        }

        public String getLogPath() {
            return logPath;
        }

        public void setLogPath(String logPath) {
            this.logPath = logPath;
        }

        public int getLogRetentionDays() {
            return logRetentionDays;
        }

        public void setLogRetentionDays(int logRetentionDays) {
            this.logRetentionDays = logRetentionDays;
        }
    }

}